<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Create a new ClientEncryption object</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="mongodb-driver-manager.construct.html">« MongoDB\Driver\Manager::__construct</a></li>
      <li style="float: right;"><a href="mongodb-driver-manager.executebulkwrite.html">MongoDB\Driver\Manager::executeBulkWrite »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="class.mongodb-driver-manager.html">MongoDB\Driver\Manager</a></li>
    <li>Create a new ClientEncryption object</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="mongodb-driver-manager.createclientencryption" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">MongoDB\Driver\Manager::createClientEncryption</h1>
  <p class="verinfo">(mongodb &gt;=1.7.0)</p><p class="refpurpose"><span class="refname">MongoDB\Driver\Manager::createClientEncryption</span> &mdash; <span class="dc-title">Create a new ClientEncryption object</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-mongodb-driver-manager.createclientencryption-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">final</span> <span class="modifier">public</span> <span class="methodname"><strong>MongoDB\Driver\Manager::createClientEncryption</strong></span>(<span class="methodparam"><span class="type">array</span> <code class="parameter">$options</code></span>): <span class="type"><span class="type MongoDB\Driver\ClientEncryption">MongoDB\Driver\ClientEncryption</span></span></div>

  <p class="para rdfs-comment">
   Constructs a new <span class="classname"><strong class="classname">MongoDB\Driver\ClientEncryption</strong></span> object with the specified options.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-mongodb-driver-manager.createclientencryption-parameters">
  <h3 class="title">参数</h3>
  <dl>
   
    <dt>
<code class="parameter">options</code></dt>

    <dd>

     <p class="para">
      <table class="doctable table">
       <caption><strong>options</strong></caption>
       
        <thead>
         <tr>
          <th>Option</th>
          <th>Type</th>
          <th>Description</th>
         </tr>

        </thead>

        <tbody class="tbody">
         
         <tr>
          <td>keyVaultClient</td>
          <td><span class="classname"><a href="class.mongodb-driver-manager.html" class="classname">MongoDB\Driver\Manager</a></span></td>
          <td>The Manager used to route data key queries to a separate MongoDB cluster. By default, the current Manager and cluster is used.</td>
         </tr>


         
         <tr>
          <td>keyVaultNamespace</td>
          <td><span class="type">string</span></td>
          <td>A fully qualified namespace (e.g. <code class="literal">&quot;databaseName.collectionName&quot;</code>) denoting the collection that contains all data keys used for encryption and decryption.</td>
         </tr>


         
         <tr>
          <td>kmsProviders</td>
          <td><span class="type">array</span></td>
          <td>
           <p class="para">
            A document containing the configuration for one or more KMS providers, which are used to encrypt data keys. Supported providers include <code class="literal">&quot;aws&quot;</code>, <code class="literal">&quot;azure&quot;</code>, <code class="literal">&quot;gcp&quot;</code>, <code class="literal">&quot;kmip&quot;</code>, and <code class="literal">&quot;local&quot;</code> and at least one must be specified.
           </p>
           <p class="para">
            The format for <code class="literal">&quot;aws&quot;</code> is as follows:
           </p>
           <div class="example-contents">
<div class="javascriptcode"><pre class="javascriptcode">aws: {
    accessKeyId: &lt;string&gt;,
    secretAccessKey: &lt;string&gt;
}</pre>
</div>
           </div>

           <p class="para">
            The format for <code class="literal">&quot;azure&quot;</code> is as follows:
           </p>
           <div class="example-contents">
<div class="javascriptcode"><pre class="javascriptcode">azure: {
    tenantId: &lt;string&gt;,
    clientId: &lt;string&gt;,
    clientSecret: &lt;string&gt;,
    identityPlatformEndpoint: &lt;optional string&gt; // Defaults to &quot;login.microsoftonline.com&quot;
}</pre>
</div>
           </div>

           <p class="para">
            The format for <code class="literal">&quot;gcp&quot;</code> is as follows:
           </p>
           <div class="example-contents">
<div class="javascriptcode"><pre class="javascriptcode">gcp: {
    email: &lt;string&gt;,
    privateKey: &lt;base64 string&gt;|&lt;MongoDB\BSON\Binary&gt;,
    endpoint: &lt;optional string&gt; // Defaults to &quot;oauth2.googleapis.com&quot;
}</pre>
</div>
           </div>

           <p class="para">
            The format for <code class="literal">&quot;kmip&quot;</code> is as follows:
           </p>
           <div class="example-contents">
<div class="javascriptcode"><pre class="javascriptcode">kmip: {
    endpoint: &lt;string&gt;
}</pre>
</div>
           </div>

           <p class="para">
            The format for <code class="literal">&quot;local&quot;</code> is as follows:
           </p>
           <div class="example-contents">
<div class="javascriptcode"><pre class="javascriptcode">local: {
    // 96-byte master key used to encrypt/decrypt data keys
    key: &lt;base64 string&gt;|&lt;MongoDB\BSON\Binary&gt;
}</pre>
</div>
           </div>

          </td>
         </tr>


         
         <tr>
          <td>tlsOptions</td>
          <td><span class="type">array</span></td>
          <td>
           <p class="para">
            A document containing the TLS configuration for one or more KMS providers. Supported providers include <code class="literal">&quot;aws&quot;</code>, <code class="literal">&quot;azure&quot;</code>, <code class="literal">&quot;gcp&quot;</code>, and <code class="literal">&quot;kmip&quot;</code>. All providers support the following options:
           </p>
           <div class="example-contents">
<div class="javascriptcode"><pre class="javascriptcode">&lt;provider&gt;: {
    tlsCaFile: &lt;optional string&gt;,
    tlsCertificateKeyFile: &lt;optional string&gt;,
    tlsCertificateKeyFilePassword: &lt;optional string&gt;
}</pre>
</div>
           </div>

          </td>
         </tr>


        </tbody>
       
      </table>

     </p>
    </dd>

   
  </dl>

 </div>


 <div class="refsect1 returnvalues" id="refsect1-mongodb-driver-manager.createclientencryption-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   Returns a new <span class="classname"><strong class="classname">MongoDB\Driver\ClientEncryption</strong></span> instance.
  </p>
 </div>


 <div class="refsect1 errors" id="refsect1-mongodb-driver-manager.createclientencryption-errors">
  <h3 class="title">错误／异常</h3>
  <ul class="simplelist">
   <li class="member">Throws <span class="classname"><a href="class.mongodb-driver-exception-invalidargumentexception.html" class="classname">MongoDB\Driver\Exception\InvalidArgumentException</a></span> on argument parsing errors.</li>
   <li class="member">Throws <span class="classname"><a href="class.mongodb-driver-exception-runtimeexception.html" class="classname">MongoDB\Driver\Exception\RuntimeException</a></span> if the extension was compiled without libmongocrypt support</li>
  </ul>
 </div>


 <div class="refsect1 changelog" id="refsect1-mongodb-driver-manager.createclientencryption-changelog">
  <h3 class="title">更新日志</h3>
  <p class="para">
   <table class="doctable informaltable">
    
     <thead>
      <tr>
       <th>版本</th>
       <th>说明</th>
      </tr>

     </thead>

     <tbody class="tbody">
      <tr>
       <td>PECL mongodb 1.12.0</td>
       <td>
        <p class="para">
         KMIP is now supported as a KMS provider for client-side encryption and
         may be configured in the <code class="literal">&quot;kmsProviders&quot;</code> option.
        </p>
        <p class="para">
         Added the <code class="literal">&quot;tlsOptions&quot;</code> option.
        </p>
       </td>
      </tr>

      <tr>
       <td>PECL mongodb 1.10.0</td>
       <td>
        Azure and GCP are now supported as KMS providers for client-side
        encryption and may be configured in the
        <code class="literal">&quot;kmsProviders&quot;</code> option. Base64-encoded strings are now
        accepted as an alternative to <span class="classname"><a href="class.mongodb-bson-binary.html" class="classname">MongoDB\BSON\Binary</a></span>
        for options within <code class="literal">&quot;kmsProviders&quot;</code>.
       </td>
      </tr>

     </tbody>
    
   </table>

  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-mongodb-driver-manager.createclientencryption-seealso">
  <h3 class="title">参见</h3>
  <ul class="simplelist">
   <li class="member"><span class="function"><strong>MongoDB\Driver\ClientEncryption::__construct()</strong></span></li>
   <li class="member"><a href="https://www.mongodb.com/docs/manual/core/security-explicit-client-side-encryption/" class="link external">&raquo;&nbsp;Explicit (Manual) Client-Side Field Level Encryption</a> in the MongoDB manual</li>
  </ul>
 </div>


</div></div></div></body></html>